# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/3/24
desc: 
sample: 
"""
import requests

host = 'http://121.11.97.201:9088/'
#id 1,2 ,10
#失败重试 3次
def get():
    url =host+'pinter/com/getSku?id=1'
    requests.get(url=url)
    data={'id':1,'test':123}
    url = host + 'pinter/com/getSku'
    resp = requests.get(url=url, params=data)
    print(resp)
    #字符串
    print(resp.text)
    #loads 字典
    print(resp.json())
    print("html数据")
    url = 'http://www.baidu.com/'
    resp = requests.get(url=url)
    print(resp.text)
    #print(resp.json())



def post():
    url =host+'pinter/com/login'
    #userName=admin&password=1234
    data={'userName':'admin','password':'1234'}
    res = requests.post(url=url,data=data)
    assert res.status_code == 200

def post_json():
    url =host+'/pinter/com/register'
    data={"userName":"test","password":"1234","gender":1,
          "phoneNum":"110","email":"beihe@163.com","address":"Beijing"}
    requests.post(url=url,json=data)

def post_file():
    url = host + '/pinter/file/api/upload2'  # 文件上传
    file = {'file': open(r'D:\my.sh', 'rb')}
    r = requests.post(url=url, files=file)

#xml
def post_xml():
    url ='http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx'
    xml = '<?xml version="1.0" encoding="utf-8"?>' \
          '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' \
          'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' \
          'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">' \
          '<soap:Body><getMobileCodeInfo xmlns="http://WebXml.com.cn/">' \
          '<mobileCode>18817982234</mobileCode><userID></userID></getMobileCodeInfo></soap:Body>' \
          '</soap:Envelope>'
    xml_header = {'Content-type': 'text/xml'}
    r = requests.post(url=url, headers=xml_header,data=xml)


if __name__ == '__main__':
    get()
    # post()
    # post_json()
    # post_file()
    # post_xml()
